package com.clms.statistics.service.impl;

import com.clms.common.R;
import com.clms.statistics.mapper.OrderMapper;
import com.clms.statistics.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: clms-third
 * @description: 订单逻辑层
 * @author: 许鹏
 * @create: 2021-07-24 15:26
 **/
@Service
@ApiModel(value = "收入的service")
public class OrderServiceImpl implements OrderService {
    @Resource
    private OrderMapper orderMapper;

    @Override
    @ApiModelProperty(value = "收入的实现")
    public R TbOrder(String ymonth) {
        List<Map> list = orderMapper.TbOrder(ymonth);
        List<String> data=new ArrayList<>();
        List<String> price=new ArrayList<>();
        for (Map map:list){
            data.add(String.valueOf(map.get("day")));
            price.add(String.valueOf(map.get("price")));
        }
        Map chardata = new HashMap<>();
        chardata.put("day" ,data);
        chardata.put("price",price);
        return R.ok().put("chardata",chardata);
    }
}
